Fix #1083 NullReferenceException in CucumberMessageFactory.ToTestStep…#1089
Open
clrudolphi wants to merge 4 commits into
Open
Fix #1083 NullReferenceException in CucumberMessageFactory.ToTestStep…#1089clrudolphi wants to merge 4 commits into
clrudolphi wants to merge 4 commits into
Conversation
…Started during scenario cleanup causes scenario to be silently omitted from HTML report. This is caused when scenario execution stops part-way through the scenario's steps, causing the Formatters' capture of the test case structure to fail. A retry of the scenario would then fail as the code assumed that the first attempt had captured all steps and hooks of the scenario.
Member
|
FYI I like to review this, but I dont think I have enough experience with these code parts. So requested copilot if it has some (small) suggestions |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a NullReferenceException in the Cucumber formatter tracking pipeline when scenarios are retried after an initial (truncated) attempt (e.g., with StopAtFirstError), by making test-case step/hook ledger entries resilient across retries and only publishing the TestCase definition once the ledger is complete.
Changes:
- Introduces per-attempt occurrence tracking for steps and hooks and uses it to lazily create/reuse ledger entries across retries.
- Moves
TestCase(definition) message publication intoPickleExecutionTracker, ensuring it’s published exactly once when the ledger is complete (or at finalization). - Updates and adds runtime tests, including a regression test covering “truncated attempt then retry reaches new step”.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Reqnroll/Formatters/ExecutionTracking/TestStepTracker.cs | Adds occurrence support and idempotent binding capture for step ledger entries. |
| Reqnroll/Formatters/ExecutionTracking/StepTrackerBase.cs | Extends base tracker identity with an Occurrence index. |
| Reqnroll/Formatters/ExecutionTracking/StepKind.cs | Adds discriminator for occurrence keying (test step vs hook). |
| Reqnroll/Formatters/ExecutionTracking/TestCaseTracker.cs | Replaces “first attempt builds everything” with lazy get-or-create ledger semantics. |
| Reqnroll/Formatters/ExecutionTracking/TestCaseExecutionTracker.cs | Adds per-attempt occurrence counters; removes TestCase publication responsibility. |
| Reqnroll/Formatters/ExecutionTracking/TestStepExecutionTracker.cs | Resolves/creates step ledger entries at StepStarted using occurrence keying. |
| Reqnroll/Formatters/ExecutionTracking/HookStepExecutionTracker.cs | Resolves/creates hook ledger entries using occurrence keying. |
| Reqnroll/Formatters/ExecutionTracking/HookStepTracker.cs | Updates hook tracker to include occurrence identity. |
| Reqnroll/Formatters/ExecutionTracking/PickleExecutionTracker.cs | Publishes TestCase message once when ledger is complete or at finalization. |
| Reqnroll/Formatters/ExecutionTracking/TestCaseExecutionTrackerFactory.cs | Updates factory signature to match new TestCaseExecutionTracker ctor. |
| Reqnroll/Formatters/ExecutionTracking/ITestCaseExecutionTrackerFactory.cs | Updates interface signature accordingly. |
| Tests/Reqnroll.RuntimeTests/Formatters/ExecutionTracking/TestStepTrackerTests.cs | Updates constructor calls to include occurrence parameter. |
| Tests/Reqnroll.RuntimeTests/Formatters/ExecutionTracking/TestStepExecutionTrackerTests.cs | Updates setup to supply IdGenerator and new step tracker ctor signature. |
| Tests/Reqnroll.RuntimeTests/Formatters/ExecutionTracking/HookStepExecutionTrackerTests.cs | Updates hook tracker ctor signature usage. |
| Tests/Reqnroll.RuntimeTests/Formatters/ExecutionTracking/TestCaseTrackerTests.cs | Adds new unit tests for get-or-create ledger behavior across retries/occurrences. |
| Tests/Reqnroll.RuntimeTests/Formatters/ExecutionTracking/PickleExecutionTrackerTests.cs | Adds regression test for truncated attempt followed by retry reaching a new step. |
| CHANGELOG.md | Adds vNext bugfix entry for #1083 (contains a typo to fix). |
| .gitignore | Ignores /.claude directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 What's changed?
This is caused when scenario execution stops part-way through the scenario's steps, causing the Formatters' capture of the test case structure to fail. A retry of the scenario would then fail as the code assumed that the first attempt had captured all steps and hooks of the scenario.
Changed the tracking of TestCase components such that it no longer assumes that the first attempt will execute all steps and hooks.
I believe that this issue highlights that 'StopAtFirstError' when False is no longer working correctly. Will track that in a separate Issue.
⚡️ What's your motivation?
#1083
This enhances stability of Formatters when a Retry mechanism is used.
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
📋 Checklist:
This text was originally taken from the template of the Cucumber project, then edited by hand. You can modify the template here.